<?php
//原始类
class zhixing{
	
	protected $zhuangshis = [];

	public function init() {
	
		echo '123';
	}
	
	//增加装饰方法
	public function beforezhuangshi(){	
		foreach($this->zhuangshis as $zhuangshi) {
			$zhuangshi->beforezhuangshi();
		}

	}
	
	//增加装饰方法
	public function afterzhuangshi() {
		$zhuangshis = array_reverse($this->zhuangshis);
		foreach($zhuangshis as $zhuangshi){ 
			$zhuangshi->afterzhuangshi;
		}
	}

	public function addzhuangshi(jilei $zhuangshi) {
	
		$this->zhuangshis[] = $zhuangshi;
	}
}

//接口类
interface jilei () {

	function beforezhuangshi(){}

	function afterzhuangshi(){}
}

//装饰类
class zhuangshi1 implements jilei {
	
	protected $color;
	
	public function __construct($color) {
	
		$this->color = $color;
	}

	public funciton beforezhuangshi() {
	
		echo "<div style='color:".$this->color."'>";
	
	}
	
	public function afterzhuangshi() {
	
		echo "</div>";
	
	}



}
